package com.sip.dbadapter.dao.domain;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 */
@Entity
@Table(name = "CONSUME_TEMPLATE")
public class ConsumeTemplate implements Serializable {

    private static final long serialVersionUID = 1L;

   // private Long consumeId;

    private Integer type;

    private String content;

    private ScanTypeRest scanTypeRest;

    private ScanTypeWs scanTypeWs;

    private ScanTypeRmi scanTypeRmi;
    
    private String templateId;
    
    private Date savedDate;
    
    private String apiName;

    public String getApiName() {
		return apiName;
	}



	public void setApiName(String apiName) {
		this.apiName = apiName;
	}



	public ConsumeTemplate() {

        //consumeId = Long.valueOf(0);
        templateId="";
    }


    
    @Id
    @Column(name = "TEMPLATE_ID", nullable=false,unique=true)
    public String getTemplateId() {
    
        return templateId;
    }

    @Column(name = "TYPE")
    public Integer getType() {

        return type;
    }

    @Column(name = "CONTENT")
    public String getContent() {

        return content;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "API_ID_REST", nullable = true)
    public ScanTypeRest getScanTypeRest() {

        return scanTypeRest;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "API_ID_WS", nullable = true)
    public ScanTypeWs getScanTypeWs() {

        return scanTypeWs;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "API_ID_RMI", nullable = true)
    public ScanTypeRmi getScanTypeRmi() {

        return scanTypeRmi;
    }
    
    
    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "DATE_SAVED",columnDefinition="TIMESTAMP DEFAULT NOW()")
    public Date getSavedDate() {
        
        return savedDate;
    }



    


    public void setType(Integer type) {

        this.type = type;
    }

    public void setContent(String content) {

        this.content = content;
    }

    public void setScanTypeWs(ScanTypeWs scanTypeWs) {

        this.scanTypeWs = scanTypeWs;
    }

    public void setScanTypeRmi(ScanTypeRmi scanTypeRmi) {

        this.scanTypeRmi = scanTypeRmi;
    }

    public void setScanTypeRest(ScanTypeRest scanTypeRest) {

        this.scanTypeRest = scanTypeRest;
    }
    
    
    public void setTemplateId(String templateId) {
    
        this.templateId = templateId;
    }
    
    
    public void setSavedDate(Date savedDate) {
    
        this.savedDate = savedDate;
    }
    
   
    @Override
    public int hashCode() {

        int result = 0;
        result = (int) (31 * result + 13);
        result = 31 * result + (type != null ? type.hashCode() : 0);
        result = 31 * result + (content != null ? content.hashCode() : 0);

        return result;
    }

    @Override
    public boolean equals(Object other) {

        if (this == other)
            return true;

        if (other == null || (this.getClass() != other.getClass())) {
            return false;
        }

        ConsumeTemplate record = (ConsumeTemplate) other;
        return (this.type != null && type.equals(record.type));

    }

}
